﻿
@using Webdiyer.WebControls.Mvc;
@model Webdiyer.WebControls.Mvc.PagedList<XQ.SP.Model.UserInfoCheckItem>
@{
    ViewBag.Title = "报表 信息列表";
    ViewBag.TextName = "报表 信息列表";
    Layout = "~/Views/Shared/Admin.cshtml";
}
<link rel="stylesheet" type="text/css" href="/Res/CSS/css/base.css" />
<link rel="stylesheet" type="text/css" href="/Res/CSS/css/styles.css" />
<div class="breadcrumb">
    <a href="javascript:void(0);">报表 信息列表</a>
</div>
<div class="pd15">
<div class="calc-box">
    <div class="filter">
        <form id="frmSearch" action="/UserInfoCheck/Rep/" method="post" onsubmit="return searchCheck(this);">
            <select id="selCity" name="City" onchange="changeCity(this)">
                <option value=''>--请选择县--</option>
            </select>
            <select id="selTown" name="Town" onchange="changeTown(this)">
                <option value=''>--请选择乡--</option>
            </select>
            <select id="selVillage" name="Village">
                <option value=''>--请选择村--</option>
            </select>
            <input type="text" id="txtBeginTime" name="BeginTime" class="input" value="@ViewBag.SearchBeginTime" placeholder="请输入统计开始时间" />
            <input type="text" id="txtEndTime" name="EndTime" class="input" value="@ViewBag.SearchEndTime" placeholder="请输入统计截止时间" />
            <script type="text/javascript" src="/Res/Files/UploadImage/Js/COM_jQuery.js"></script>
            <script type="text/javascript" src="/Res/CSS/js/datetimepicker.min.js"></script>
            <script type="text/javascript">
                $("#txtBeginTime").datetimepicker({
                    format:"Y-m-d H:m:s",
                    timepicker:false,
                });
                $("#txtEndTime").datetimepicker({
                    format:"Y-m-d H:m:s",
                    timepicker:false,
                });
            </script>
            <input type="hidden" id="txtHandler" name="handler" value="" />
            <button type="submit" id="btnSearch" class="btn" onclick="changeStatus('search')">确定</button>
            <button type="submit" id="btnExport" class="btn" onclick="changeStatus('export')">导出</button>
        </form>
    </div>
</div>

<table cellpadding="0" cellspacing="0" width="100%" class="pub-table pub-table-hover" style="margin-top:15px;">
    <tr>
        <th style="width:30px">序号</th>
        
                        <th>区域</th>
                        <th>应检数</th>
                        <th>累计检测人数</th>
                        <th>累计既往</th>
                        <th>累计新发现</th>
                        <th>本日检测人数</th>
                        <th>本日既往</th>
                        <th>本日新发现</th>
    </tr>
    @{
        int tCount = 0;
        int f1 = 0, f2 = 0, f3 = 0, f4 = 0, f5 = 0, f6 = 0, f7 = 0;

        System.Data.DataTable dt = (System.Data.DataTable)ViewBag.dt;
        foreach (System.Data.DataRow dr in dt.Rows)
        {
            tCount++;
            f1 += Convert.ToInt32(dr[1]);
            f2 += Convert.ToInt32(dr[2]);
            f3 += Convert.ToInt32(dr[3]);
            f4 += Convert.ToInt32(dr[4]);
            f5 += Convert.ToInt32(dr[5]);
            f6 += Convert.ToInt32(dr[6]);
            f7 += Convert.ToInt32(dr[7]);
        <tr>
            <td align="center">@tCount</td>
            <td align="center" id="field0">@dr[0]</td>
            <td align="center" id="field1">@dr[1]</td>
            <td align="center" id="field2">@dr[2]</td>
            <td align="center" id="field3">@dr[3]</td>
            <td align="center" id="field4">@dr[4]</td>
            <td align="center" id="field5">@dr[5]</td>
            <td align="center" id="field6">@dr[6]</td>
            <td align="center" id="field6">@dr[7]</td>
        </tr>
        }
        <tr>
            <td align="center">-</td>
            <td align="center" id="field0">总计</td>
            <td align="center" id="field1">@f1</td>
            <td align="center" id="field2">@f2</td>
            <td align="center" id="field3">@f3</td>
            <td align="center" id="field4">@f4</td>
            <td align="center" id="field5">@f5</td>
            <td align="center" id="field6">@f6</td>
            <td align="center" id="field6">@f7</td>
        </tr>
    }
</table>
    </div>


<script type="text/javascript" src="/Res/CSS/js/jquery.js"></script>
<script type="text/javascript" src="/Res/CSS/js/jquery-form.js"></script>
<script type="text/javascript">
    var dict = @Html.Raw(ViewBag.City);
    var selectedCity = '@ViewBag.SearchCity';
    var selectedTown = '@ViewBag.SearchTown';
    var selectedVillage = '@ViewBag.SearchVillage';

    $(function(){

        dict = dict||[];
        var list = [];
        for(var i=0,l=dict.length;i<l;i++){
            if(!dict[i]["City"])continue;
            // 判断是否存在
            var exist = false;
            for(var j=0,n=list.length;j<n;j++){
                if(list[j]["City"]==dict[i]["City"]){
                    exist=true;
                    break;
                }
            }

            if(exist)continue;

            list.push(dict[i]);
        }
        var city=document.getElementById("selCity");
        city.options.length=0;
        city.options[0]=new Option("--请选择县--",'');
        for(var i=0,l=list.length;i<l;i++){
            city.options[i+1]=new Option(list[i]["City"],list[i]["City"]);
            if(list[i]["City"]==selectedCity){
                city.options[i+1].selected = true;
                changeCity(city);
            }
        }
    });
    function changeCity(el){
        var city =  el.options[el.selectedIndex].value;

        var list = [];
        for(var i=0,l=dict.length;i<l;i++){
            if(!dict[i]["Towns"])continue;
            if(dict[i]["City"]!=city)continue;
            // 判断是否存在
            var exist = false;
            for(var j=0,n=list.length;j<n;j++){
                if(dict[i]["City"]==city&&list[j]["Towns"]==dict[i]["Towns"]){
                    exist=true;
                    break;
                }
            }

            if(exist)continue;

            list.push(dict[i]);
        }

        var town=document.getElementById("selTown");
        var village=document.getElementById("selVillage");
        //清空上次的选项
        town.options.length=0;
        village.options.length=0;
        town.options[0]=new Option("--请选择乡--",'');
        for(var i=0,l=list.length;i<l;i++){
            town.options[i+1]=new Option(list[i]["Towns"],list[i]["Towns"]);
            if(list[i]["Towns"]==selectedTown){
                town.options[i+1].selected = true;
                changeTown(town);
            }
        }
    }
    function changeTown(el){
        var town =  el.options[el.selectedIndex].value;

        var list = [];
        for(var i=0,l=dict.length;i<l;i++){
            if(!dict[i]["Village"])continue;
            if(dict[i]["Towns"]!=town)continue;
            // 判断是否存在
            var exist = false;
            for(var j=0,n=list.length;j<n;j++){
                if(dict[i]["Towns"]==town&&list[j]["Village"]==dict[i]["Village"]){
                    exist=true;
                    break;
                }
            }

            if(exist)continue;

            list.push(dict[i]);
        }

        var village=document.getElementById("selVillage");
        //清空上次的选项
        village.options.length=0;
        village.options[0]=new Option("--请选择村--",'');
        for(var i=0,l=list.length;i<l;i++){
            village.options[i+1]=new Option(list[i]["Village"],list[i]["Village"]);
            if(list[i]["Village"]==selectedVillage)
                village.options[i+1].selected = true;
        }
    }

    function searchCheck() {
        //top.showLoading();
        return true;
    }

    var isCheckAll = false;
    function swapCheck() {
        if (isCheckAll) {
            $("input[type='checkbox']").each(function () {
                this.checked = false;
            });
            isCheckAll = false;
        } else {
            $("input[type='checkbox']").each(function () {
                this.checked = true;
            });
            isCheckAll = true;
        }
    }
    function Getcheckbox() {
        var str = document.getElementsByName("checkId");
        var objarray = str.length;
        var chestr = "";
        for (i = 0; i < objarray; i++) {
            if (str[i].checked == true) {
                chestr += str[i].value + ",";
            }
        }
        chestr = chestr.substr(0, chestr.length - 1);
        if (chestr.length <= 0) {
            alert("请选择要删除的选项");
        }
        DelId(chestr);
    }
    function DelId(ids) {
        if (!confirm('您确定删除吗?')) {
            return;
        }
        $.ajax({
            type: 'POST',
            url: '/UserInfoCheck/Deletes?ids=' + ids + "&uid=@UsersInfo.GetUsersID()",
            data: { ids: ids },
            dataType: "json",
            success: function (msg) {
                if (msg == "false") {
                    alert("删除信息错误，删除失败！");
                }
                else {
                    alert("删除成功");
                    window.location = "/UserInfoCheck/List?pageIndex=@ViewBag.pageIndex";
                }
            }
        });
    }

    function changeStatus(flag) {
        $("#txtHandler").val(flag);
    }
</script>

